import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/login.vue'
import Admin from '../views/admin.vue'
import Welcome from '../views/admin/welcome.vue'
import Chapter from '../views/admin/chapter.vue'
import Section from '../views/admin/section.vue'
import Course from '../views/admin/course.vue'
import Category from '../views/admin/category.vue'
import Teacher from '../views/admin/teacher.vue'
import File from '../views/admin/file.vue'
import Content from '../views/admin/content.vue'
import User from '../views/admin/user.vue'
import Resource from '../views/admin/resource.vue'
import Role from '../views/admin/role.vue'
import Member from '../views/admin/member.vue'
import Sms from '../views/admin/sms.vue'

const routes = [
  {
    path: '/',
    redirect: "/login"
  },
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/',
    name: 'admin',
    component: Admin,
    meta:{
      loginRequire:true
    },
    children:[{
      path: 'welcome',
      name: 'welcome',
      component: Welcome,
    },{
      path: 'business/chapter',
      name: 'business/chapter',
      component: Chapter,
    },{
      path: 'business/section',
      name: 'business/section',
      component: Section,
    },{
      path: 'business/course',
      name: 'business/course',
      component: Course,
    },
      {
        path: 'business/category',
        name: 'business/category',
        component: Category,
      },
      {
        path: 'business/teacher',
        name: 'business/teacher',
        component: Teacher,
      },
      {
        path: 'file/file',
        name: 'file/file',
        component: File,
      },
      {
        path: 'business/content',
        name: 'business/content',
        component: Content,
      },
      {
        path: 'system/user',
        name: 'system/user',
        component: User,
      },
      {
        path: 'system/resource',
        name: 'system/resource',
        component: Resource,
      },
      {
        path: 'system/role',
        name: 'system/role',
        component: Role,
      },
      {
        path: 'business/member',
        name: 'business/member',
        component: Member,
      },
      {
        path: 'business/sms',
        name: 'business/sms',
        component: Sms,
      }


    ]

  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: function () {
      return import(/* webpackChunkName: "about" */ '../views/About.vue')
    }
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
